openapi: 3.0.1
info:
  title: langfuse
  version: ''
  description: >-
    ## Authentication


    Authenticate with the API using Basic Auth, get API keys in the project
    settings:


    - username: Langfuse Public Key

    - password: Langfuse Secret Key
paths:
  /api/public/dataset-items:
    post:
      description: Create a dataset item, upserts on id
      operationId: datasetItems_create
      tags:
        - DatasetItems
      parameters: []
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DatasetItem'
        '400':
          description: ''
          content:
            application/json:
              schema: {}
        '401':
          description: ''
          content:
            application/json:
              schema: {}
        '403':
          description: ''
          content:
            application/json:
              schema: {}
        '404':
          description: ''
          content:
            application/json:
              schema: {}
        '405':
          description: ''
          content:
            application/json:
              schema: {}
      security: &ref_0
        - BasicAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateDatasetItemRequest'
  /api/public/dataset-items/{id}:
    get:
      description: Get a specific dataset item
      operationId: datasetItems_get
      tags:
        - DatasetItems
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DatasetItem'
        '400':
          description: ''
          content:
            application/json:
              schema: {}
        '401':
          description: ''
          content:
            application/json:
              schema: {}
        '403':
          description: ''
          content:
            application/json:
              schema: {}
        '404':
          description: ''
          content:
            application/json:
              schema: {}
        '405':
          description: ''
          content:
            application/json:
              schema: {}
      security: *ref_0
  /api/public/dataset-run-items:
    post:
      description: Create a dataset run item
      operationId: datasetRunItems_create
      tags:
        - DatasetRunItems
      parameters: []
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DatasetRunItem'
        '400':
          description: ''
          content:
            application/json:
              schema: {}
        '401':
          description: ''
          content:
            application/json:
              schema: {}
        '403':
          description: ''
          content:
            application/json:
              schema: {}
        '404':
          description: ''
          content:
            application/json:
              schema: {}
        '405':
          description: ''
          content:
            application/json:
              schema: {}
      security: *ref_0
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateDatasetRunItemRequest'
  /api/public/datasets/{datasetName}:
    get:
      description: Get a dataset and its items
      operationId: datasets_get
      tags:
        - Datasets
      parameters:
        - name: datasetName
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Dataset'
        '400':
          description: ''
          content:
            application/json:
              schema: {}
        '401':
          description: ''
          content:
            application/json:
              schema: {}
        '403':
          description: ''
          content:
            application/json:
              schema: {}
        '404':
          description: ''
          content:
            application/json:
              schema: {}
        '405':
          description: ''
          content:
            application/json:
              schema: {}
      security: *ref_0
  /api/public/datasets:
    post:
      description: Create a dataset
      operationId: datasets_create
      tags:
        - Datasets
      parameters: []
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Dataset'
        '400':
          description: ''
          content:
            application/json:
              schema: {}
        '401':
          description: ''
          content:
            application/json:
              schema: {}
        '403':
          description: ''
          content:
            application/json:
              schema: {}
        '404':
          description: ''
          content:
            application/json:
              schema: {}
        '405':
          description: ''
          content:
            application/json:
              schema: {}
      security: *ref_0
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateDatasetRequest'
  /api/public/datasets/{datasetName}/runs/{runName}:
    get:
      description: Get a dataset run and its items
      operationId: datasets_getRuns
      tags:
        - Datasets
      parameters:
        - name: datasetName
          in: path
          required: true
          schema:
            type: string
        - name: runName
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DatasetRun'
        '400':
          description: ''
          content:
            application/json:
              schema: {}
        '401':
          description: ''
          content:
            application/json:
              schema: {}
        '403':
          description: ''
          content:
            application/json:
              schema: {}
        '404':
          description: ''
          content:
            application/json:
              schema: {}
        '405':
          description: ''
          content:
            application/json:
              schema: {}
      security: *ref_0
  /api/public/health:
    get:
      description: Check health of API and database
      operationId: health_health
      tags:
        - Health
      parameters: []
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HealthResponse'
        '400':
          description: ''
          content:
            application/json:
              schema: {}
        '401':
          description: ''
          content:
            application/json:
              schema: {}
        '403':
          description: ''
          content:
            application/json:
              schema: {}
        '404':
          description: ''
          content:
            application/json:
              schema: {}
        '405':
          description: ''
          content:
            application/json:
              schema: {}
        '503':
          description: ''
  /api/public/ingestion:
    post:
      description: Ingest multiple events to Langfuse
      operationId: ingestion_batch
      tags:
        - Ingestion
      parameters: []
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IngestionResponse'
        '400':
          description: ''
          content:
            application/json:
              schema: {}
        '401':
          description: ''
          content:
            application/json:
              schema: {}
        '403':
          description: ''
          content:
            application/json:
              schema: {}
        '404':
          description: ''
          content:
            application/json:
              schema: {}
        '405':
          description: ''
          content:
            application/json:
              schema: {}
      security: *ref_0
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                batch:
                  type: array
                  items:
                    $ref: '#/components/schemas/IngestionEvent'
              required:
                - batch
  /api/public/metrics/daily:
    get:
      description: Get daily metrics of the Langfuse project
      operationId: metrics_daily
      tags:
        - Metrics
      parameters:
        - name: page
          in: query
          required: false
          schema:
            type: integer
            nullable: true
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            nullable: true
        - name: traceName
          in: query
          description: Optional filter by the name of the trace
          required: false
          schema:
            type: string
            nullable: true
        - name: userId
          in: query
          description: Optional filter by the userId associated with the trace
          required: false
          schema:
            type: string
            nullable: true
        - name: tags
          in: query
          description: Optional filter for metrics where traces include all of these tags
          required: false
          schema:
            type: array
            items:
              type: string
              nullable: true
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DailyMetrics'
        '400':
          description: ''
          content:
            application/json:
              schema: {}
        '401':
          description: ''
          content:
            application/json:
              schema: {}
        '403':
          description: ''
          content:
            application/json:
              schema: {}
        '404':
          description: ''
          content:
            application/json:
              schema: {}
        '405':
          description: ''
          content:
            application/json:
              schema: {}
      security: *ref_0
  /api/public/observations/{observationId}:
    get:
      description: Get a specific observation
      operationId: observations_get
      tags:
        - Observations
      parameters:
        - name: observationId
          in: path
          description: >-
            The unique langfuse identifier of an observation, can be an event,
            span or generation
          required: true
          schema:
            type: string
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ObservationsView'
        '400':
          description: ''
          content:
            application/json:
              schema: {}
        '401':
          description: ''
          content:
            application/json:
              schema: {}
        '403':
          description: ''
          content:
            application/json:
              schema: {}
        '404':
          description: ''
          content:
            application/json:
              schema: {}
        '405':
          description: ''
          content:
            application/json:
              schema: {}
      security: *ref_0
  /api/public/observations:
    get:
      description: Get a list of observations
      operationId: observations_getMany
      tags:
        - Observations
      parameters:
        - name: page
          in: query
          required: false
          schema:
            type: integer
            nullable: true
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            nullable: true
        - name: name
          in: query
          required: false
          schema:
            type: string
            nullable: true
        - name: userId
          in: query
          required: false
          schema:
            type: string
            nullable: true
        - name: type
          in: query
          required: false
          schema:
            type: string
            nullable: true
        - name: traceId
          in: query
          required: false
          schema:
            type: string
            nullable: true
        - name: parentObservationId
          in: query
          required: false
          schema:
            type: string
            nullable: true
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ObservationsViews'
        '400':
          description: ''
          content:
            application/json:
              schema: {}
        '401':
          description: ''
          content:
            application/json:
              schema: {}
        '403':
          description: ''
          content:
            application/json:
              schema: {}
        '404':
          description: ''
          content:
            application/json:
              schema: {}
        '405':
          description: ''
          content:
            application/json:
              schema: {}
      security: *ref_0
  /api/public/projects:
    get:
      operationId: projects_get
      tags:
        - Projects
      parameters: []
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Projects'
        '400':
          description: ''
          content:
            application/json:
              schema: {}
        '401':
          description: ''
          content:
            application/json:
              schema: {}
        '403':
          description: ''
          content:
            application/json:
              schema: {}
        '404':
          description: ''
          content:
            application/json:
              schema: {}
        '405':
          description: ''
          content:
            application/json:
              schema: {}
      security: *ref_0
  /api/public/prompts:
    get:
      description: Get a specific prompt
      operationId: prompts_get
      tags:
        - Prompts
      parameters:
        - name: name
          in: query
          required: true
          schema:
            type: string
        - name: version
          in: query
          required: false
          schema:
            type: integer
            nullable: true
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Prompt'
        '400':
          description: ''
          content:
            application/json:
              schema: {}
        '401':
          description: ''
          content:
            application/json:
              schema: {}
        '403':
          description: ''
          content:
            application/json:
              schema: {}
        '404':
          description: ''
          content:
            application/json:
              schema: {}
        '405':
          description: ''
          content:
            application/json:
              schema: {}
      security: *ref_0
    post:
      description: Create a specific prompt
      operationId: prompts_create
      tags:
        - Prompts
      parameters: []
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Prompt'
        '400':
          description: ''
          content:
            application/json:
              schema: {}
        '401':
          description: ''
          content:
            application/json:
              schema: {}
        '403':
          description: ''
          content:
            application/json:
              schema: {}
        '404':
          description: ''
          content:
            application/json:
              schema: {}
        '405':
          description: ''
          content:
            application/json:
              schema: {}
      security: *ref_0
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreatePromptRequest'
  /api/public/scores:
    post:
      description: Add a score to the database, upserts on id
      operationId: score_create
      tags:
        - Score
      parameters: []
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Score'
        '400':
          description: ''
          content:
            application/json:
              schema: {}
        '401':
          description: ''
          content:
            application/json:
              schema: {}
        '403':
          description: ''
          content:
            application/json:
              schema: {}
        '404':
          description: ''
          content:
            application/json:
              schema: {}
        '405':
          description: ''
          content:
            application/json:
              schema: {}
      security: *ref_0
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateScoreRequest'
    get:
      description: Get scores
      operationId: score_get
      tags:
        - Score
      parameters:
        - name: page
          in: query
          required: false
          schema:
            type: integer
            nullable: true
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            nullable: true
        - name: userId
          in: query
          required: false
          schema:
            type: string
            nullable: true
        - name: name
          in: query
          required: false
          schema:
            type: string
            nullable: true
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Scores'
        '400':
          description: ''
          content:
            application/json:
              schema: {}
        '401':
          description: ''
          content:
            application/json:
              schema: {}
        '403':
          description: ''
          content:
            application/json:
              schema: {}
        '404':
          description: ''
          content:
            application/json:
              schema: {}
        '405':
          description: ''
          content:
            application/json:
              schema: {}
      security: *ref_0
  /api/public/scores/{scoreId}:
    delete:
      description: Delete a score
      operationId: score_delete
      tags:
        - Score
      parameters:
        - name: scoreId
          in: path
          description: The unique langfuse identifier of a score
          required: true
          schema:
            type: string
      responses:
        '204':
          description: ''
        '400':
          description: ''
          content:
            application/json:
              schema: {}
        '401':
          description: ''
          content:
            application/json:
              schema: {}
        '403':
          description: ''
          content:
            application/json:
              schema: {}
        '404':
          description: ''
          content:
            application/json:
              schema: {}
        '405':
          description: ''
          content:
            application/json:
              schema: {}
      security: *ref_0
  /api/public/sessions/{sessionId}:
    get:
      description: Get a session
      operationId: sessions_get
      tags:
        - Sessions
      parameters:
        - name: sessionId
          in: path
          description: The unique id of a session
          required: true
          schema:
            type: string
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SessionWithTraces'
        '400':
          description: ''
          content:
            application/json:
              schema: {}
        '401':
          description: ''
          content:
            application/json:
              schema: {}
        '403':
          description: ''
          content:
            application/json:
              schema: {}
        '404':
          description: ''
          content:
            application/json:
              schema: {}
        '405':
          description: ''
          content:
            application/json:
              schema: {}
      security: *ref_0
  /api/public/traces/{traceId}:
    get:
      description: Get a specific trace
      operationId: trace_get
      tags:
        - Trace
      parameters:
        - name: traceId
          in: path
          description: The unique langfuse identifier of a trace
          required: true
          schema:
            type: string
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TraceWithFullDetails'
        '400':
          description: ''
          content:
            application/json:
              schema: {}
        '401':
          description: ''
          content:
            application/json:
              schema: {}
        '403':
          description: ''
          content:
            application/json:
              schema: {}
        '404':
          description: ''
          content:
            application/json:
              schema: {}
        '405':
          description: ''
          content:
            application/json:
              schema: {}
      security: *ref_0
  /api/public/traces:
    get:
      description: Get list of traces
      operationId: trace_list
      tags:
        - Trace
      parameters:
        - name: page
          in: query
          required: false
          schema:
            type: integer
            nullable: true
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            nullable: true
        - name: userId
          in: query
          required: false
          schema:
            type: string
            nullable: true
        - name: name
          in: query
          required: false
          schema:
            type: string
            nullable: true
        - name: orderBy
          in: query
          description: >-
            Format of the string sort_by=timestamp.asc (id, timestamp, name,
            userId, release, version, public, bookmarked, sessionId)
          required: true
          schema:
            type: string
        - name: tags
          in: query
          description: Only traces that include all of these tags will be returned.
          required: false
          schema:
            type: array
            items:
              type: string
              nullable: true
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Traces'
        '400':
          description: ''
          content:
            application/json:
              schema: {}
        '401':
          description: ''
          content:
            application/json:
              schema: {}
        '403':
          description: ''
          content:
            application/json:
              schema: {}
        '404':
          description: ''
          content:
            application/json:
              schema: {}
        '405':
          description: ''
          content:
            application/json:
              schema: {}
      security: *ref_0
components:
  schemas:
    Trace:
      title: Trace
      type: object
      properties:
        id:
          type: string
          description: The unique identifier of a trace
        timestamp:
          type: string
          format: date-time
        name:
          type: string
          nullable: true
        input:
          nullable: true
        output:
          nullable: true
        sessionId:
          type: string
          nullable: true
        release:
          type: string
          nullable: true
        version:
          type: string
          nullable: true
        userId:
          type: string
          nullable: true
        metadata:
          nullable: true
        tags:
          type: array
          items:
            type: string
          nullable: true
        public:
          type: boolean
          nullable: true
          description: Public traces are accessible via url without login
      required:
        - id
        - timestamp
    TraceWithDetails:
      title: TraceWithDetails
      type: object
      properties:
        htmlPath:
          type: string
          description: Path of trace in Langfuse UI
        latency:
          type: number
          format: double
          description: Latency of trace in seconds
        totalCost:
          type: number
          format: double
          description: Cost of trace in USD
        observations:
          type: array
          items:
            type: string
          description: List of observation ids
        scores:
          type: array
          items:
            type: string
          description: List of score ids
      required:
        - htmlPath
        - latency
        - totalCost
        - observations
        - scores
      allOf:
        - $ref: '#/components/schemas/Trace'
    TraceWithFullDetails:
      title: TraceWithFullDetails
      type: object
      properties:
        htmlPath:
          type: string
          description: Path of trace in Langfuse UI
        totalCost:
          type: number
          format: double
          description: Cost of trace in USD
        observations:
          type: array
          items:
            $ref: '#/components/schemas/ObservationsView'
        scores:
          type: array
          items:
            $ref: '#/components/schemas/Score'
      required:
        - htmlPath
        - totalCost
        - observations
        - scores
      allOf:
        - $ref: '#/components/schemas/Trace'
    Session:
      title: Session
      type: object
      properties:
        id:
          type: string
        createdAt:
          type: string
          format: date-time
        projectId:
          type: string
      required:
        - id
        - createdAt
        - projectId
    SessionWithTraces:
      title: SessionWithTraces
      type: object
      properties:
        traces:
          type: array
          items:
            $ref: '#/components/schemas/Trace'
      required:
        - traces
      allOf:
        - $ref: '#/components/schemas/Session'
    Observation:
      title: Observation
      type: object
      properties:
        id:
          type: string
        traceId:
          type: string
          nullable: true
        type:
          type: string
        name:
          type: string
          nullable: true
        startTime:
          type: string
          format: date-time
        endTime:
          type: string
          format: date-time
          nullable: true
        completionStartTime:
          type: string
          format: date-time
          nullable: true
        model:
          type: string
          nullable: true
        modelParameters:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/MapValue'
          nullable: true
        input:
          nullable: true
        version:
          type: string
          nullable: true
        metadata:
          nullable: true
        output:
          nullable: true
        usage:
          $ref: '#/components/schemas/Usage'
          nullable: true
        level:
          $ref: '#/components/schemas/ObservationLevel'
        statusMessage:
          type: string
          nullable: true
        parentObservationId:
          type: string
          nullable: true
        promptId:
          type: string
          nullable: true
      required:
        - id
        - type
        - startTime
        - level
    ObservationsView:
      title: ObservationsView
      type: object
      properties:
        modelId:
          type: string
          nullable: true
        inputPrice:
          type: number
          format: double
          nullable: true
        outputPrice:
          type: number
          format: double
          nullable: true
        totalPrice:
          type: number
          format: double
          nullable: true
        calculatedInputCost:
          type: number
          format: double
          nullable: true
        calculatedOutputCost:
          type: number
          format: double
          nullable: true
        calculatedTotalCost:
          type: number
          format: double
          nullable: true
        latency:
          type: number
          format: double
          nullable: true
      allOf:
        - $ref: '#/components/schemas/Observation'
    Usage:
      title: Usage
      type: object
      properties:
        input:
          type: integer
          nullable: true
        output:
          type: integer
          nullable: true
        total:
          type: integer
          nullable: true
        unit:
          $ref: '#/components/schemas/ModelUsageUnit'
          nullable: true
        inputCost:
          type: number
          format: double
          nullable: true
        outputCost:
          type: number
          format: double
          nullable: true
        totalCost:
          type: number
          format: double
          nullable: true
    Score:
      title: Score
      type: object
      properties:
        id:
          type: string
        traceId:
          type: string
        name:
          type: string
        value:
          type: number
          format: double
        observationId:
          type: string
          nullable: true
        timestamp:
          type: string
          format: date-time
        comment:
          type: string
          nullable: true
      required:
        - id
        - traceId
        - name
        - value
        - timestamp
    Dataset:
      title: Dataset
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        projectId:
          type: string
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
        items:
          type: array
          items:
            $ref: '#/components/schemas/DatasetItem'
        runs:
          type: array
          items:
            type: string
      required:
        - id
        - name
        - projectId
        - createdAt
        - updatedAt
        - items
        - runs
    DatasetItem:
      title: DatasetItem
      type: object
      properties:
        id:
          type: string
        status:
          $ref: '#/components/schemas/DatasetStatus'
        input: {}
        expectedOutput:
          nullable: true
        sourceObservationId:
          type: string
          nullable: true
        datasetId:
          type: string
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
      required:
        - id
        - status
        - input
        - datasetId
        - createdAt
        - updatedAt
    DatasetRunItem:
      title: DatasetRunItem
      type: object
      properties:
        id:
          type: string
        datasetRunId:
          type: string
        datasetItemId:
          type: string
        observationId:
          type: string
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
      required:
        - id
        - datasetRunId
        - datasetItemId
        - observationId
        - createdAt
        - updatedAt
    DatasetRun:
      title: DatasetRun
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        datasetId:
          type: string
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
        datasetRunItems:
          type: array
          items:
            $ref: '#/components/schemas/DatasetRunItem'
      required:
        - id
        - name
        - datasetId
        - createdAt
        - updatedAt
        - datasetRunItems
    ModelUsageUnit:
      title: ModelUsageUnit
      type: string
      enum:
        - CHARACTERS
        - TOKENS
        - MILLISECONDS
        - SECONDS
        - IMAGES
    ObservationLevel:
      title: ObservationLevel
      type: string
      enum:
        - DEBUG
        - DEFAULT
        - WARNING
        - ERROR
    MapValue:
      title: MapValue
      oneOf:
        - type: string
          nullable: true
        - type: integer
          nullable: true
        - type: boolean
          nullable: true
        - type: array
          items:
            type: string
          nullable: true
    DatasetStatus:
      title: DatasetStatus
      type: string
      enum:
        - ACTIVE
        - ARCHIVED
    CreateDatasetItemRequest:
      title: CreateDatasetItemRequest
      type: object
      properties:
        datasetName:
          type: string
        input: {}
        expectedOutput:
          nullable: true
        id:
          type: string
          nullable: true
      required:
        - datasetName
        - input
    CreateDatasetRunItemRequest:
      title: CreateDatasetRunItemRequest
      type: object
      properties:
        runName:
          type: string
        datasetItemId:
          type: string
        observationId:
          type: string
      required:
        - runName
        - datasetItemId
        - observationId
    CreateDatasetRequest:
      title: CreateDatasetRequest
      type: object
      properties:
        name:
          type: string
      required:
        - name
    HealthResponse:
      title: HealthResponse
      type: object
      properties:
        version:
          type: string
          description: Langfuse server version
          example: 1.25.0
        status:
          type: string
          example: OK
      required:
        - version
        - status
    IngestionEvent:
      title: IngestionEvent
      oneOf:
        - type: object
          allOf:
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - trace-create
            - $ref: '#/components/schemas/TraceEvent'
          required:
            - type
        - type: object
          allOf:
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - score-create
            - $ref: '#/components/schemas/ScoreEvent'
          required:
            - type
        - type: object
          allOf:
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - event-create
            - $ref: '#/components/schemas/CreateEventEvent'
          required:
            - type
        - type: object
          allOf:
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - generation-create
            - $ref: '#/components/schemas/CreateGenerationEvent'
          required:
            - type
        - type: object
          allOf:
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - generation-update
            - $ref: '#/components/schemas/UpdateGenerationEvent'
          required:
            - type
        - type: object
          allOf:
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - span-create
            - $ref: '#/components/schemas/CreateSpanEvent'
          required:
            - type
        - type: object
          allOf:
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - span-update
            - $ref: '#/components/schemas/UpdateSpanEvent'
          required:
            - type
        - type: object
          allOf:
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - sdk-log
            - $ref: '#/components/schemas/SDKLogEvent'
          required:
            - type
        - type: object
          allOf:
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - observation-create
            - $ref: '#/components/schemas/CreateObservationEvent'
          required:
            - type
        - type: object
          allOf:
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - observation-update
            - $ref: '#/components/schemas/UpdateObservationEvent'
          required:
            - type
    ObservationType:
      title: ObservationType
      type: string
      enum:
        - SPAN
        - GENERATION
        - EVENT
    IngestionUsage:
      title: IngestionUsage
      oneOf:
        - $ref: '#/components/schemas/Usage'
        - $ref: '#/components/schemas/OpenAIUsage'
    OpenAIUsage:
      title: OpenAIUsage
      type: object
      properties:
        promptTokens:
          type: integer
          nullable: true
        completionTokens:
          type: integer
          nullable: true
        totalTokens:
          type: integer
          nullable: true
    OptionalObservationBody:
      title: OptionalObservationBody
      type: object
      properties:
        traceId:
          type: string
          nullable: true
        name:
          type: string
          nullable: true
        startTime:
          type: string
          format: date-time
          nullable: true
        metadata:
          nullable: true
        input:
          nullable: true
        output:
          nullable: true
        level:
          $ref: '#/components/schemas/ObservationLevel'
          nullable: true
        statusMessage:
          type: string
          nullable: true
        parentObservationId:
          type: string
          nullable: true
        version:
          type: string
          nullable: true
    CreateEventBody:
      title: CreateEventBody
      type: object
      properties:
        id:
          type: string
          nullable: true
      allOf:
        - $ref: '#/components/schemas/OptionalObservationBody'
    UpdateEventBody:
      title: UpdateEventBody
      type: object
      properties:
        id:
          type: string
      required:
        - id
      allOf:
        - $ref: '#/components/schemas/OptionalObservationBody'
    CreateSpanBody:
      title: CreateSpanBody
      type: object
      properties:
        endTime:
          type: string
          format: date-time
          nullable: true
      allOf:
        - $ref: '#/components/schemas/CreateEventBody'
    UpdateSpanBody:
      title: UpdateSpanBody
      type: object
      properties:
        endTime:
          type: string
          format: date-time
          nullable: true
      allOf:
        - $ref: '#/components/schemas/UpdateEventBody'
    CreateGenerationBody:
      title: CreateGenerationBody
      type: object
      properties:
        completionStartTime:
          type: string
          format: date-time
          nullable: true
        model:
          type: string
          nullable: true
        modelParameters:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/MapValue'
          nullable: true
        usage:
          $ref: '#/components/schemas/IngestionUsage'
          nullable: true
        promptName:
          type: string
          nullable: true
        promptVersion:
          type: integer
          nullable: true
      allOf:
        - $ref: '#/components/schemas/CreateSpanBody'
    UpdateGenerationBody:
      title: UpdateGenerationBody
      type: object
      properties:
        completionStartTime:
          type: string
          format: date-time
          nullable: true
        model:
          type: string
          nullable: true
        modelParameters:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/MapValue'
          nullable: true
        usage:
          $ref: '#/components/schemas/IngestionUsage'
          nullable: true
        promptName:
          type: string
          nullable: true
        promptVersion:
          type: integer
          nullable: true
      allOf:
        - $ref: '#/components/schemas/UpdateSpanBody'
    ObservationBody:
      title: ObservationBody
      type: object
      properties:
        id:
          type: string
          nullable: true
        traceId:
          type: string
          nullable: true
        type:
          $ref: '#/components/schemas/ObservationType'
        name:
          type: string
          nullable: true
        startTime:
          type: string
          format: date-time
          nullable: true
        endTime:
          type: string
          format: date-time
          nullable: true
        completionStartTime:
          type: string
          format: date-time
          nullable: true
        model:
          type: string
          nullable: true
        modelParameters:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/MapValue'
          nullable: true
        input:
          nullable: true
        version:
          type: string
          nullable: true
        metadata:
          nullable: true
        output:
          nullable: true
        usage:
          $ref: '#/components/schemas/Usage'
          nullable: true
        level:
          $ref: '#/components/schemas/ObservationLevel'
          nullable: true
        statusMessage:
          type: string
          nullable: true
        parentObservationId:
          type: string
          nullable: true
      required:
        - type
    TraceBody:
      title: TraceBody
      type: object
      properties:
        id:
          type: string
          nullable: true
        timestamp:
          type: string
          format: date-time
          nullable: true
        name:
          type: string
          nullable: true
        userId:
          type: string
          nullable: true
        input:
          nullable: true
        output:
          nullable: true
        sessionId:
          type: string
          nullable: true
        release:
          type: string
          nullable: true
        version:
          type: string
          nullable: true
        metadata:
          nullable: true
        tags:
          type: array
          items:
            type: string
          nullable: true
        public:
          type: boolean
          nullable: true
          description: Make trace publicly accessible via url
    SDKLogBody:
      title: SDKLogBody
      type: object
      properties:
        log: {}
      required:
        - log
    ScoreBody:
      title: ScoreBody
      type: object
      properties:
        id:
          type: string
          nullable: true
        traceId:
          type: string
        name:
          type: string
        value:
          type: number
          format: double
        observationId:
          type: string
          nullable: true
        comment:
          type: string
          nullable: true
      required:
        - traceId
        - name
        - value
    BaseEvent:
      title: BaseEvent
      type: object
      properties:
        id:
          type: string
        timestamp:
          type: string
        metadata: {}
      required:
        - id
        - timestamp
        - metadata
    TraceEvent:
      title: TraceEvent
      type: object
      properties:
        body:
          $ref: '#/components/schemas/TraceBody'
      required:
        - body
      allOf:
        - $ref: '#/components/schemas/BaseEvent'
    CreateObservationEvent:
      title: CreateObservationEvent
      type: object
      properties:
        body:
          $ref: '#/components/schemas/ObservationBody'
      required:
        - body
      allOf:
        - $ref: '#/components/schemas/BaseEvent'
    UpdateObservationEvent:
      title: UpdateObservationEvent
      type: object
      properties:
        body:
          $ref: '#/components/schemas/ObservationBody'
      required:
        - body
      allOf:
        - $ref: '#/components/schemas/BaseEvent'
    ScoreEvent:
      title: ScoreEvent
      type: object
      properties:
        body:
          $ref: '#/components/schemas/ScoreBody'
      required:
        - body
      allOf:
        - $ref: '#/components/schemas/BaseEvent'
    SDKLogEvent:
      title: SDKLogEvent
      type: object
      properties:
        body:
          $ref: '#/components/schemas/SDKLogBody'
      required:
        - body
      allOf:
        - $ref: '#/components/schemas/BaseEvent'
    CreateGenerationEvent:
      title: CreateGenerationEvent
      type: object
      properties:
        body:
          $ref: '#/components/schemas/CreateGenerationBody'
      required:
        - body
      allOf:
        - $ref: '#/components/schemas/BaseEvent'
    UpdateGenerationEvent:
      title: UpdateGenerationEvent
      type: object
      properties:
        body:
          $ref: '#/components/schemas/UpdateGenerationBody'
      required:
        - body
      allOf:
        - $ref: '#/components/schemas/BaseEvent'
    CreateSpanEvent:
      title: CreateSpanEvent
      type: object
      properties:
        body:
          $ref: '#/components/schemas/CreateSpanBody'
      required:
        - body
      allOf:
        - $ref: '#/components/schemas/BaseEvent'
    UpdateSpanEvent:
      title: UpdateSpanEvent
      type: object
      properties:
        body:
          $ref: '#/components/schemas/UpdateSpanBody'
      required:
        - body
      allOf:
        - $ref: '#/components/schemas/BaseEvent'
    CreateEventEvent:
      title: CreateEventEvent
      type: object
      properties:
        body:
          $ref: '#/components/schemas/CreateEventBody'
      required:
        - body
      allOf:
        - $ref: '#/components/schemas/BaseEvent'
    IngestionSuccess:
      title: IngestionSuccess
      type: object
      properties:
        id:
          type: string
        status:
          type: integer
      required:
        - id
        - status
    IngestionError:
      title: IngestionError
      type: object
      properties:
        id:
          type: string
        status:
          type: integer
        message:
          type: string
          nullable: true
        error:
          nullable: true
      required:
        - id
        - status
    IngestionResponse:
      title: IngestionResponse
      type: object
      properties:
        successes:
          type: array
          items:
            $ref: '#/components/schemas/IngestionSuccess'
        errors:
          type: array
          items:
            $ref: '#/components/schemas/IngestionError'
      required:
        - successes
        - errors
    DailyMetrics:
      title: DailyMetrics
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/DailyMetricsDetails'
          description: A list of daily metrics, only days with ingested data are included.
        meta:
          $ref: '#/components/schemas/utilsMetaResponse'
      required:
        - data
        - meta
    DailyMetricsDetails:
      title: DailyMetricsDetails
      type: object
      properties:
        date:
          type: string
        countTraces:
          type: integer
        totalCost:
          type: number
          format: double
        usage:
          type: array
          items:
            $ref: '#/components/schemas/UsageByModel'
      required:
        - date
        - countTraces
        - totalCost
        - usage
    UsageByModel:
      title: UsageByModel
      type: object
      description: >-
        Daily usage of a given model. Usage corresponds to the unit set for the
        specific model (e.g. tokens).
      properties:
        model:
          type: string
        inputUsage:
          type: integer
        outputUsage:
          type: integer
        totalUsage:
          type: integer
      required:
        - model
        - inputUsage
        - outputUsage
        - totalUsage
    Observations:
      title: Observations
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/Observation'
        meta:
          $ref: '#/components/schemas/utilsMetaResponse'
      required:
        - data
        - meta
    ObservationsViews:
      title: ObservationsViews
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/ObservationsView'
        meta:
          $ref: '#/components/schemas/utilsMetaResponse'
      required:
        - data
        - meta
    Projects:
      title: Projects
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/Project'
      required:
        - data
    Project:
      title: Project
      type: object
      properties:
        id:
          type: string
        name:
          type: string
      required:
        - id
        - name
    CreatePromptRequest:
      title: CreatePromptRequest
      type: object
      properties:
        name:
          type: string
        isActive:
          type: boolean
        prompt:
          type: string
        config:
          nullable: true
      required:
        - name
        - isActive
        - prompt
    Prompt:
      title: Prompt
      type: object
      properties:
        name:
          type: string
        version:
          type: integer
        prompt:
          type: string
        config: {}
      required:
        - name
        - version
        - prompt
        - config
    CreateScoreRequest:
      title: CreateScoreRequest
      type: object
      properties:
        id:
          type: string
          nullable: true
        traceId:
          type: string
        name:
          type: string
        value:
          type: number
          format: double
        observationId:
          type: string
          nullable: true
        comment:
          type: string
          nullable: true
      required:
        - traceId
        - name
        - value
    Scores:
      title: Scores
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/Score'
        meta:
          $ref: '#/components/schemas/utilsMetaResponse'
      required:
        - data
        - meta
    Traces:
      title: Traces
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/TraceWithDetails'
        meta:
          $ref: '#/components/schemas/utilsMetaResponse'
      required:
        - data
        - meta
    Sort:
      title: Sort
      type: object
      properties:
        id:
          type: string
      required:
        - id
    utilsMetaResponse:
      title: utilsMetaResponse
      type: object
      properties:
        page:
          type: integer
          description: current page number
        limit:
          type: integer
          description: number of items per page
        totalItems:
          type: integer
          description: number of total items given the current filters/selection (if any)
        totalPages:
          type: integer
          description: number of total pages given the current limit
      required:
        - page
        - limit
        - totalItems
        - totalPages
  securitySchemes:
    BasicAuth:
      type: http
      scheme: basic
